More mechanical fixes.
authorrobertlipe@gmail.com <robertlipe@gmail.com@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 31 Dec 2013 22:28:52 +0000 (22:28 +0000)
committerrobertlipe@gmail.com <robertlipe@gmail.com@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 31 Dec 2013 22:28:52 +0000 (22:28 +0000)
http://xkcd.com/1296

git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4686 f51c46e8-681c-474f-0cfe-069cfd0219fb

gpsbabel/kml.cc
gpsbabel/navicache.cc
gpsbabel/osm.cc
gpsbabel/skytraq.cc
gpsbabel/stmsdf.cc
gpsbabel/tiger.cc
gpsbabel/waypt.cc
gpsbabel/xol.cc

index b5267b6923c12972dd3b7ce418ba36a0b484b789..24850fcfe9153083d85f1555d3cddb2b0a23770f 100644 (file)
@@ -286,50 +286,21 @@ void wpt_e(xg_string args, const QXmlStreamAttributes* unused)
   wpt_tmp_queued = 0;
 }
 
-#if NEW_STRINGS
 void wpt_name(xg_string args, const QXmlStreamAttributes* unused)
 {
   wpt_tmp->shortname = args;
 }
-#else
-void wpt_name(xg_string args, const QXmlStreamAttributes* unused)
-{
-  if (args) {
-    wpt_tmp->shortname = xstrdup(args);
-  }
-}
-#endif
 
-#if NEW_STRINGS
 void wpt_desc(const QString& args, const QXmlStreamAttributes* unused)
 {
   wpt_tmp->description += args.trimmed();
 }
-#else
-void wpt_desc(xg_string args, const QXmlStreamAttributes* unused)
-{
-  if (args) {
-    char* tmp, *c;
-
-    tmp = xstrdup((char*)args);
-    c = lrtrim(tmp);
-    if (*c) {
-      wpt_tmp->description = xstrappend(wpt_tmp->description, c);
-    }
-    xfree(tmp);
-  }
-}
-#endif
 
 void wpt_time(xg_string args, const QXmlStreamAttributes* unused)
 {
   wpt_tmp->SetCreationTime(xml_parse_time(args));
 }
-#if NEW_STRINGS
 void wpt_coord(const QString& args, const QXmlStreamAttributes* attrv)
-#else
-void wpt_coord(xg_string args, const QXmlStreamAttributes* attrv)
-#endif
 {
   int n = 0;
   double lat, lon, alt;
@@ -360,21 +331,13 @@ void trk_coord(xg_string args, const QXmlStreamAttributes* attrv)
   int n = 0;
 
   route_head* trk_head = route_head_alloc();
-#if NEW_STRINGS 
+
   QString iargs = args;
   if (!wpt_tmp->shortname.isEmpty()) {
-#else
-  if (wpt_tmp->shortname) {
-#endif
-    trk_head->rte_name  = xstrdup(wpt_tmp->shortname);
+    trk_head->rte_name  = wpt_tmp->shortname;
   }
   track_add_head(trk_head);
-#if NEW_STRINGS
   while ((n = sscanf(CSTR(iargs), "%lf,%lf,%lf%n", &lon, &lat, &alt, &consumed)) > 0) {
-#else
-  while ((n = sscanf(args, "%lf,%lf,%lf%n", &lon, &lat, &alt, &consumed)) > 0) {
-#endif
-
     trkpt = waypt_new();
     trkpt->latitude = lat;
     trkpt->longitude = lon;
@@ -389,11 +352,7 @@ void trk_coord(xg_string args, const QXmlStreamAttributes* attrv)
     }
 
     track_add_wpt(trk_head, trkpt);
-#if NEW_STRINGS
     iargs = iargs.mid(consumed);
-#else
-    args += consumed;
-#endif
   }
 }
 
@@ -672,11 +631,7 @@ void kml_output_trkdescription(const route_head* header, computed_trkdata* td)
   writer->writeStartElement("description");
 
   hwriter.writeStartElement("table");
-#if NEW_STRINGS 
   if (!header->rte_desc.isEmpty()) {
-#else
-  if (header->rte_desc) {
-#endif
     kml_td(hwriter, "Description", QString(" %1 ").arg(header->rte_desc));
   }
   kml_td(hwriter, "Distance", QString(" %1 %2 ").arg(QString::number(distance, 'f', 1)).arg(distance_units));
@@ -935,11 +890,7 @@ static void kml_output_point(const waypoint* waypointp, kml_point_type pt_type)
   if (export_points) {
     writer->writeStartElement("Placemark");
     if (atoi(opt_labels)) {
-#if NEW_STRINGS 
       writer->writeOptionalTextElement("name", waypointp->shortname);
-#else
-      writer->writeOptionalTextElement("name", QString::fromUtf8(waypointp->shortname));
-#endif
     }
     writer->writeEmptyElement("snippet");
     kml_output_description(waypointp);
@@ -1479,12 +1430,7 @@ static void kml_geocache_pr(const waypoint* waypointp)
   writer->writeEndElement(); // Close Style tag
 
   writer->writeStartElement("ExtendedData");
-#if NEW_STRINGS 
   if (!waypointp->shortname.isEmpty()) {
-#else
-  if (waypointp->shortname) {
-#endif
-
     kml_write_data_element("gc_num", waypointp->shortname);
   }
 
@@ -1577,11 +1523,7 @@ static void kml_waypt_pr(const waypoint* waypointp)
       writer->writeTextElement("description", link.url_);
     }
   } else {
-#if NEW_STRINGS 
     if (waypointp->shortname != waypointp->description) {
-#else
-    if (strcmp(waypointp->shortname, waypointp->description)) {
-#endif
       writer->writeOptionalTextElement("description", waypointp->description);
     }
   }
@@ -2117,28 +2059,17 @@ kml_wr_position(waypoint* wpt)
   }
 
   /* We want our waypoint to have a name, but not our trackpoint */
-#if NEW_STRINGS 
   if (wpt->shortname.isEmpty()) {
-#else
-  if (!wpt->shortname) {
-#endif
     if (wpt->fix == fix_none) {
-      wpt->shortname = xstrdup("ESTIMATED Position");
+      wpt->shortname = "ESTIMATED Position";
     } else {
-      wpt->shortname = xstrdup("Position");
+      wpt->shortname = "Position";
     }
   }
 
   switch (wpt->fix) {
   case fix_none:
-#if NEW_STRINGS 
     wpt->shortname = "ESTIMATED Position";
-#else
-    if (wpt->shortname) {
-      xfree(wpt->shortname);
-    }
-    wpt->shortname = xstrdup("ESTIMATED Position");
-#endif
     break;
   case fix_unknown:
     break;
index 04d464ba94657b6a61b9a8a16b24b8b443502752..9f9ecc62f85efa4daf4cd9ca8d4477003f9f4c37 100644 (file)
@@ -106,13 +106,13 @@ NaviReadCache(const QXmlStreamReader& reader)
   if (a.hasAttribute("cache_id")) {
     int n = a.value("cache_id").toString().toInt();
     QString fn = QString("N%1").arg(n, 5, 16, QChar('0'));
-    wpt_tmp->shortname = xstrdup(fn);
+    wpt_tmp->shortname = fn;
 
     UrlLink l(QString(NC_URL) + QString::number(n));
     wpt_tmp->AddUrlLink(l);
   }
   if (a.hasAttribute("name")) {
-    wpt_tmp->description = xstrdup(a.value("name").toString());
+    wpt_tmp->description = a.value("name").toString();
   }
   if (a.hasAttribute("user_name")) {
     gc_data->placer = a.value("user_name").toString();
index 6e62a2009f90dd69ab855551609b2c1e957481cf..1018af9801ba301aba9e99a32778ce4e60b03eba 100644 (file)
@@ -532,24 +532,11 @@ osm_node_tag(xg_string args, const QXmlStreamAttributes* attrv)
   str = osm_strip_html(value);
 
   if (strcmp(key, "name") == 0) {
-#if NEW_STRINGS
     if (wpt->shortname.isEmpty()) {
       wpt->shortname = str;
     }
-#else
-    if (! wpt->shortname) {
-      wpt->shortname = xstrdup(str);
-    }
-#endif
   } else if (strcmp(key, "name:en") == 0) {
-#if NEW_STRINGS
     wpt->shortname = str;
-#else
-    if (wpt->shortname) {
-      xfree(wpt->shortname);
-    }
-    wpt->shortname = xstrdup(str);
-#endif
   } else if ((ikey = osm_feature_ikey(key)) >= 0) {
     char* id = osm_feature_symbol(ikey, value);
     wpt->icon_descr = id;
@@ -557,23 +544,12 @@ osm_node_tag(xg_string args, const QXmlStreamAttributes* attrv)
       xfree(id);
     }
   } else if (strcmp(key, "note") == 0) {
-#if NEW_STRINGS
     if (wpt->notes.isEmpty()) {
       wpt->notes = str;
     } else {
       wpt->notes += "; ";
       wpt->notes += str;
     }
-#else
-    if (wpt->notes) {
-      char* tmp;
-      xasprintf(&tmp, "%s; %s", CSTRc(wpt->notes), str);
-      xfree(wpt->notes);
-      wpt->notes = tmp;
-    } else {
-      wpt->notes = xstrdup(str);
-    }
-#endif
   } else if (strcmp(key, "gps:hdop") == 0) {
     wpt->hdop = atof(str);
   } else if (strcmp(key, "gps:vdop") == 0) {
@@ -648,24 +624,11 @@ osm_way_tag(xg_string args, const QXmlStreamAttributes* attrv)
   str = osm_strip_html(value);
 
   if (strcmp(key, "name") == 0) {
-#if NEW_STRINGS
     if (rte->rte_name.isEmpty()) {
       rte->rte_name = str;
     }
-#else
-    if (! rte->rte_name) {
-      rte->rte_name = xstrdup(str);
-    }
-#endif
   } else if (strcmp(key, "name:en") == 0) {
-#if NEW_STRINGS
     rte->rte_name = str;
-#else
-    if (rte->rte_name) {
-      xfree(rte->rte_name);
-    }
-    rte->rte_name = xstrdup(str);
-#endif
   }
 
   xfree(str);
index 8d0206a36004e3811d03e499633131cc23fc0b26..4aff7291b763c4ccb044f45e83d22a72b8bfa333 100644 (file)
@@ -643,8 +643,8 @@ state_init(struct read_state* pst)
   route_head* track;
 
   track = route_head_alloc();
-  track->rte_name = xstrdup("SkyTraq tracklog");
-  track->rte_desc = xstrdup("SkyTraq GPS tracklog data");
+  track->rte_name = "SkyTraq tracklog";
+  track->rte_desc = "SkyTraq GPS tracklog data";
   track_add_head(track);
 
   pst->route_head_ = track;
index fbebe01a39ff25525fc8a6c0d2902d5addaaae55..4404516b4a6f3bcaf157b3f568cb2109b6e52ade 100644 (file)
@@ -214,11 +214,11 @@ finalize_tracks(void)
         if (trackno > 1) {
           xasprintf(&track->rte_name, "%s (%d)", CSTR(rte_name), trackno);
         } else {
-          track->rte_name      = xstrdup(rte_name);
+          track->rte_name = rte_name;
         }
       }
       if (rte_desc != NULL) {
-        track->rte_desc = xstrdup(rte_desc);
+        track->rte_desc = rte_desc;
       }
     }
     track_add_wpt(track, wpt);
index 8a64ff64746eb79facbe3c03545f2b760cc86c6b..ea902aa96dcd1264d088e3bc7baff2b16eb6573b 100644 (file)
@@ -170,7 +170,7 @@ data_read(void)
 
       wpt_tmp->longitude = lon;
       wpt_tmp->latitude = lat;
-      wpt_tmp->description = xstrdup(desc);
+      wpt_tmp->description = desc;
       wpt_tmp->shortname = mkshort(mkshort_handle, desc);
 
       waypt_add(wpt_tmp);
index 285eb5a11bbe8854cba0430af2fda95ca542575c..158be2b1f956bff82f0015c9e17edddc33a9dfa1 100644 (file)
@@ -69,18 +69,6 @@ waypt_dupe(const waypoint* wpt)
    */
   waypoint* tmp = new waypoint;
   *tmp = *wpt;
-#if NEW_STRINGS
-#else
-  if (wpt->shortname) {
-    tmp->shortname = xstrdup(wpt->shortname);
-  }
-  if (wpt->description) {
-    tmp->description = xstrdup(wpt->description);
-  }
-  if (wpt->notes) {
-    tmp->notes = xstrdup(wpt->notes);
-  }
-#endif
 
   tmp->icon_descr = wpt->icon_descr;
 
@@ -174,7 +162,7 @@ waypt_add(waypoint* wpt)
    * try to be sure that we have these fields even if just by
    * copying them from elsewhere.
    */
-#if NEW_STRINGS
+
   // Note tests for isNull here as some formats intentionally set "".
   // This is kind of goofy, but it emulates the C string implementation.
   if (wpt->shortname.isNull()) {
@@ -188,22 +176,7 @@ waypt_add(waypoint* wpt)
       wpt->shortname = QString("WPT%1").arg(n);
     }
   }
-#else
-  if (wpt->shortname == NULL) {
-    if (wpt->description) {
-      wpt->shortname = xstrdup(wpt->description);
-    } else if (wpt->notes) {
-      wpt->shortname = xstrdup(wpt->notes);
-    } else {
-      /* Last ditch:  make up a name */
-      char *sn;
-      xasprintf(&sn, "WPT%03d", waypt_ct);
-      wpt->shortname = sn;
-    }
-  }
-#endif
 
-#if NEW_STRINGS
   if (wpt->description.isEmpty()) {
     if (!wpt->notes.isNull()) {
       wpt->description = wpt->notes;
@@ -213,20 +186,6 @@ waypt_add(waypoint* wpt)
       }
     }
   }
-#else
-  if (wpt->description == NULL || strlen(wpt->description) == 0) {
-    if (wpt->description) {
-      xfree(wpt->description);
-    }
-    if (wpt->notes != NULL) {
-      wpt->description = xstrdup(wpt->notes);
-    } else  {
-      if (wpt->shortname != NULL) {
-        wpt->description = xstrdup(wpt->shortname);
-      }
-    }
-  }
-#endif
 
   update_common_traits(wpt);
 
@@ -442,18 +401,6 @@ waypt_free(waypoint* wpt)
   /*
    * This and waypt_dupe should be closely synced.
    */
-#if NEW_STRINGS
-#else
-  if (wpt->shortname) {
-    xfree(wpt->shortname);
-  }
-  if (wpt->description) {
-    xfree(wpt->description);
-  }
-  if (wpt->notes) {
-    xfree(wpt->notes);
-  }
-#endif
 
   if (wpt->gc_data != &empty_gc_data) {
     geocache_data* gc_data = (geocache_data*)wpt->gc_data;
index 24e612d3c7df494d1d59d61fa24f269a11a12df7..fa7ba5dc0748a1be5c2995e7e8ae20f6740023dd 100644 (file)
@@ -79,15 +79,15 @@ xol_shape(xg_string args, const QXmlStreamAttributes* attrv)
 
   if (attrv->hasAttribute("name")) {
     if (wpt) {
-      wpt->shortname = xstrdup(attrv->value("name").toString().toUtf8().constData());
+      wpt->shortname = attrv->value("name").toString();
     } else if (trk) {
-      trk->rte_name = xstrdup(attrv->value("name").toString().toUtf8().constData());
+      trk->rte_name = attrv->value("name").toString();
     }
   }
 
   if (wpt) {
     if (attrv->hasAttribute("comment")) {
-      wpt->notes = xstrdup(attrv->value("comment").toString().toUtf8().constData());
+      wpt->notes = attrv->value("comment").toString();
     }
 
     if (attrv->hasAttribute("alt")) {